package net.wofly.sale.shoppingcart.validator;

import org.apache.commons.lang3.StringUtils;

/**
 * @author siqingwei
 */
public class ShoppingCartValidator {

    /**
     * 换行符
     */
    private static String lineSeparator = System.getProperty("line.separator");

    public static String validateAddCommodityToCartParams(String userID, Integer shoppingCartType, String commodityID, Integer num) {
        StringBuffer stringBuffer = new StringBuffer();
        if (StringUtils.isBlank(userID)) {
            stringBuffer.append("用户ID不能为空").append(lineSeparator);
        }
        
        if (null == shoppingCartType) {
            stringBuffer.append("购物车类型不能为空").append(lineSeparator);
        }

        if (StringUtils.isBlank(commodityID)) {
            stringBuffer.append("商品ID不能为空").append(lineSeparator);
        }

        if (num == null) {
            stringBuffer.append("商品数量不能为空").append(lineSeparator);
        }
        return stringBuffer.toString();
    }

    public static String validateChangeCommodityNumParams(String cartListID, Integer num) {
        StringBuffer stringBuffer = new StringBuffer();
        if (StringUtils.isBlank(cartListID)) {
            stringBuffer.append("购物车列表ID不能为空").append(lineSeparator);
        }

        if (num == null) {
            stringBuffer.append("商品数量不能为空").append(lineSeparator);
        }
        return stringBuffer.toString();
    }

    public static String validateDelCommodityParams(String cartListID) {
        StringBuffer stringBuffer = new StringBuffer();
        if (StringUtils.isBlank(cartListID)) {
            stringBuffer.append("购物车列表ID不能为空").append(lineSeparator);
        }
        return stringBuffer.toString();
    }

    public static String validateGetCartListParams(String userID, Integer shoppingCartType) {
        StringBuffer stringBuffer = new StringBuffer();
        if (StringUtils.isBlank(userID)) {
            stringBuffer.append("用户ID不能为空").append(lineSeparator);
        }
        if (null == shoppingCartType) {
            stringBuffer.append("购物车类型不能为空").append(lineSeparator);
        }
        return stringBuffer.toString();
    }

    public static String validateCommitCartListParams(String userID) {
        StringBuffer stringBuffer = new StringBuffer();
        if (StringUtils.isBlank(userID)) {
            stringBuffer.append("用户ID不能为空").append(lineSeparator);
        }
        return stringBuffer.toString();
    }
}
